package com.company.thread;

/**
 * @description: T1 和 T2 共享资源 i
 * @author: ruoan
 * @date: 2020/10/21 17:15
 */
public class MyThread3 {

    public static void main(String[] args) {
        RunnableDemo runnableDemo = new RunnableDemo();
        new Thread(runnableDemo,"T1").start();
        new Thread(runnableDemo,"T2").start();


        System.out.println(Thread.currentThread().getName()+": "+"end...");
    }



}


class RunnableDemo implements Runnable {
    int i = 5;


    @Override
    public void run() {
        while (i > 0) {
            System.out.println(Thread.currentThread().getName() + ": " + "i:" + i--);
        }
    }
}

